 #include <cstdio>
 #include <iostream>
 #include <string>
 #include <vector>
 #include <cstdlib>
 #include <algorithm>
 
 using namespace std;
 
 //递归和回溯
 void CalculateSumCore(vector<int> &src, int sum, int start, vector<int> &resultIndex, vector<int> &resultValue) {
     if (sum == 0) {
         cout << "下标为：";
         for (auto s : resultIndex)
             cout << s << " ";
         cout << endl;
         cout << "下标对应值：";
         for (auto s : resultValue)
            cout << s << "+";
         cout << endl;
     }
     else if (sum >= src[start] && start < src.size()) {
         resultIndex.push_back(start);
         resultValue.push_back(src[start]);
         CalculateSumCore(src, sum - src[start], start + 1, resultIndex, resultValue);
         //注意入“栈”才需要出“栈”即是回溯的过程
         resultIndex.pop_back();
         resultValue.pop_back();
         CalculateSumCore(src, sum, start + 1, resultIndex, resultValue);
     }
 }
 
 void CalculateSum(vector<int> &src, int sum) {
     sort(src.begin(), src.end());
     if (sum < 0 && src.empty())
         return;
     vector<int> resultIndex; //存储结果值的下标
     vector<int> resultValue; //存储结果值
     CalculateSumCore(src, sum, 0, resultIndex, resultValue);
 }
 
 int main()
 {
     vector<int> src{10, 20, 10, 30, 50, 100, 60 };
     int sum;
     cin >> sum;
     CalculateSum(src, sum);
     return 0;
 }